home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
- //
- // Filename : container.h
- // Description : Header file for Container class
- // Author : Marnich van Rensburg (2002)
- //
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
-
- #include "tetramino.h"
- #include <time.h> // For time function
- #include <stdlib.h> // For srand and rand functions
- #include <math.h> // For abs()
-
- //----------------------------------------------------------------------------------------
- // External Globals
- //----------------------------------------------------------------------------------------
-
- extern bool SoundActive;
- extern bool StarFieldActive;
-
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- #ifndef CONTAINER_H
- #define CONTAINER_H
-
- #define CON_WIDTH 36
- #define CON_HEIGHT 20
- #define CON_EMPTY_CELL 0
- #define CON_LINE_CELL 8
-
- #define CON_ROTATION_STEP 10.0f
- #define CON_ROTATION_FSTEP 10.0f
-
- #define CON_RADIUS 5.715f
-
- //Container Actions
- #define CON_NONE 0
- #define CON_ROTATE_RIGHT 1
- #define CON_ROTATE_LEFT 2
- #define CON_CHECK_FOR_LINES 3
- #define CON_SHOW_LINES 4
- #define CON_REMOVE_LINES 5
- #define CON_START_NEXT 6
- #define CON_GAME_OVER 7
-
-
- #define CON_HOVER_MAX 1
-
-
-
- //----------------------------------------------------------------------------------------
- // Class Definition for Container Class
- //----------------------------------------------------------------------------------------
-
- class Container
- {
-
- //---------------------- Public -------------------------
-
- public:
-
- // Data Members
- float x, y, z; // (OGL) (x, y, z) position of container
-
- // Member Funtions
- Container(); // Constructor
- bool Collision(char x, char y); // Checks for collisions at x, y
- void DoAction(); // (OGL) will perform the current action
- char GetAction(); // (OGL) will start a new action if CurActive = NONE
- char GetMatrix(char x, char y); // Returns the value of the Container cell at (x, y)
- char GetNoOfLinesFound(); // Returns No of lines found in the container
- float GetRotation(); // (OGL) Returns the current x rotation angle
- bool Inside(char x, char y); // Checks if the (x, y) is inside the container
- void New(); // Init/Clears the Container
- bool PlaceTet(Tetramino& ref_Tet); // Place tetramino onto container
- void RemoveTet(Tetramino& ref_Tet); // Removes tetramino from container
- void ResetNoOfLinesFound(); // Sets No of lines found to 0
- void RotateLeft(); // (OGL) sets new rotation angle (left) based on ROTATION_STEP
- void RotateRight(); // (OGL) sets new rotation angle (Right) based on ROTATION_STEP
- void SetAction(char Action); // (OGL) will start a new action if CurActive = NONE
- void SetMatrix(char x, char y, char Data); // Places cell data at (x, y) in the container
- void SetPos(float x, float y, float z); // Set (x,y,z) position of container
- void SetRotation(float angle); // (OGL) Sets the current x rotation angle
-
-
- //---------------------- Private -------------------------
-
- private:
-
- // Data Members
- char CurAction; // (OGL) The current action being performed by the container
- char Matrix[36][20]; // Stores the container data
- char NoOfLinesFound; // Holds prev amount of lines detected
- float xCurRotation; // (OGL) Current x rotation angle of container
- float xNewRotation; // (OGL) New Rotation anle ensures smooth rotation
-
- // Member Funtions
- void ClearLine(char y); // Clears the line at y and moves all the rows above it one down
- void Hover(); // Makes the container appear to hover
- bool Line(char y); // Returns true if there is a line at y
- float Random(); // Used for hovering in random directions
- char WrapX(char x); // Wraps around in container x-axis
-
- };//Class Container
-
- #endif;